@model IEnumerable<lucienneCRMApp.Models.Helpers.Chat>

@{
    ViewBag.Title = "Index";
}


    <div>
        <label for="username">Enter Username:</label>
        <input type="text" id="username" />
        </br>
        </br>
        <label for="msg">Enter Message:</label>
        <input type="text" id="msg" maxlength="100"  />
        <input type="button" id="broadcast" value="broadcast" />
        </br>
        </br>
        <ul id="messages">
        </ul>
    </div>
    <script type="text/javascript">
        $(function () {
            // Proxy created on the fly
            var chat = $.connection.chat;

            // Declare a function on the chat hub so the server can invoke it
            chat.addMessage = function (username, message) {
                $('#messages').append('<li>'+ username + ' - ' + message + '</li>');
            };

            $("#broadcast").click(function () {
                // Call the chat method on the server
                chat.send($('#username').val(), $('#msg').val());
            });

            // Start the connection
            $.connection.hub.start();
        });
    </script>

